CC = gcc
CFLAGS = -g -Wall -pthread -I.
LDFLAGS= -Llib -Wl,-rpath,lib
LIBS = -lm

SRCS = cstr.c cbuf.c clist.c carray.c cstack.c chash.c cconf.c cdate.c cfile.c clog.c ciconv.c cbit.c cdes.c cbin.c cmd5.c cdes3.c csha1.c csha256.c cbig_num.c crsa.c
TEST_SRCS = test_cstr.c test_chash.c test_cdes.c test_cbin.c test_cfile.c test_cdes3.c test_csha1.c test_csha256.c test_cbig_num.c test_clog.c test_cmd5.c
ALL_SRCS = $(SRCS) $(TEST_SRCS)

OBJS = $(SRCS:.c=.o)
ALL_OBJS = $(ALL_SRCS:.c=.o)

TEST_EXEC = $(TEST_SRCS:.c=)

all: $(TEST_EXEC)

$(TEST_EXEC): $(ALL_OBJS)
	$(CC) $(OBJS) $@.o -o $@ $(CFLAGS) $(LDFLAGS) $(LIBS)

lib: $(OBJS)
	ar crs libcutil.a $(OBJS)

%o: %c
	$(CC) $(CFLAGS) -c -o $@ $<

clean: 
	rm -f *~ $(ALL_OBJS) libcutil.a



